package com.springbootblog.config;

import com.springbootblog.interceptor.FontendInterceptor;
import com.springbootblog.interceptor.TokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * 拦截器配置
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer
{
//    @Resource
//    private TokenInterceptor tokenInterceptor ;
//
//    @Resource
//    private FontendInterceptor fontendInterceptor ;

    @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        // 注册拦截器 并配置拦截所有方法  除了count方法
//         registry.addInterceptor(new FontendInterceptor()).addPathPatterns("/**").excludePathPatterns("/count");
        registry.addInterceptor(new FontendInterceptor()).addPathPatterns("/java/**");
        registry.addInterceptor(new TokenInterceptor()).addPathPatterns("/java/**");
    }
}